<%-- 
    Document   : Pantalla_Dar_Permisos_Admin
    Created on : 28-nov-2013, 15:48:27
    Author     : julian
--%>

<%@page import="GestorBDatos.Usuario"%>
<%@page import="java.util.List"%>
<%@page import="GestorBDatos.UsuarioJpaController"%>
<%@page import="javax.persistence.Persistence"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<jsp:include page="Control_Sesion.jsp"/>

<!DOCTYPE html>

<html  lang="es">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Seguridad informática</title>
        <link rel="stylesheet" href="css/bootstrap.css">
        <link rel="stylesheet" href="css/offcanvas.css">
        <link href="css/navbar.css" rel="stylesheet">
        <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <script src="js/offcanvas.js"></script>
    </head>
    <body>
        <%
            EntityManagerFactory emf = Persistence.createEntityManagerFactory("Seguridad_InformaticaPU");
            UsuarioJpaController bd = new UsuarioJpaController(emf);
            List<Usuario> listaUsers = bd.getUsusariosAltaNoAdmin();

            HttpSession sesion = request.getSession();
            String login = (String) sesion.getAttribute("Login");
            Usuario usuario = bd.findUsuario(login);
        %>

        <div class="container">
            <!-- Static navbar -->
            <div class="navbar navbar-default" role="navigation">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a href="Pantalla_Dar_De_Alta_Admin.jsp" class="navbar-brand" >Seguridad informatica</a>
                </div>
                <div class="navbar-collapse collapse">
                    <ul class="nav navbar-nav">
                        <li><a><%=usuario.getLogin()%></a></li>
                    </ul>
                    <ul class="nav navbar-nav navbar-right">
                        <li class="active"><a href="Cerrar_Sesion.jsp">Cerrar Sesión</a></li>
                    </ul>
                </div><!--/.nav-collapse -->
            </div>
        </div> <!-- /container -->

        <div class="container">

            <div class="row row-offcanvas row-offcanvas-left">

                <div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar" role="navigation">
                    <div class="list-group">
                        <a href="Pantalla_Dar_De_Alta_Admin.jsp" title="Dar de alta usuarios" class="list-group-item ">Dar de alta</a>
                        <a href="Pantalla_Dar_De_Baja_Admin.jsp" title="Dar de baja usuarios" class="list-group-item ">Dar de baja</a>
                        <a href="Pantalla_Dar_Permisos_Admin.jsp" title="Dar permisos a usuarios" class="list-group-item active">Dar permisos</a>
                        <a href="Pantalla_Datos_Admin.jsp" title="Ver mis datos" class="list-group-item ">Ver datos</a>
                    </div>
                </div><!--/span-->

                <div class="col-xs-12 col-sm-9">
                    <p class="pull-left visible-xs">
                        <button type="button" class="btn btn-primary btn-xs" data-toggle="offcanvas">Menu</button>
                    </p>
                    <div class="jumbotron">
                        <h2>Dar permisos de admin</h2>
                    </div>
                    <div class="row">

                        <form method="post">
                            <div class="table-responsive">
                                <table  class="table">
                                    <thead>
                                        <tr>
                                            <th><strong>Alta</strong></th>
                                            <th><strong>Login</strong></th>
                                            <th><strong>Nombre</strong></th>
                                            <th><strong>Apellido</strong></th>
                                            <th><strong>Correo</strong></th>
                                        </tr>
                                    </thead>

                                    <tbody>

                                        <%
                                            for (int i = 0; i < listaUsers.size(); i++) {
                                        %>
                                        <tr>
                                            <td> <p><input type="checkbox" name="check" value=<%=listaUsers.get(i).getLogin()%> /> </td>
                                            <td> <%=listaUsers.get(i).getLogin()%> </td>
                                            <td> <%=listaUsers.get(i).getNombre()%> </td> 
                                            <td> <%=listaUsers.get(i).getApellidos()%> </td> 
                                            <td> <%=listaUsers.get(i).getCorreo()%> </td>
                                        </tr>
                                        <%
                                            }
                                            sesion.setAttribute("listaUsersParaDarPermisosAdmin", listaUsers);
                                        %>

                                    </tbody>

                                </table>
                            </div>
                            <input type="submit" class="btn btn-primary" onclick="this.form.action = 'Procesar_Dar_De_Alta_Admin.jsp'" value="Dar de alta">
                        </form>

                    </div><!--/row-->
                </div><!--/span-->


            </div><!--/row-->

        </div><!--/.container-->

    </body>
</html>
